# myapp/urls.py  
  
from django.urls import path,include  
from . import views  

from rest_framework.routers import DefaultRouter  
from rest_framework.authtoken import views as authtoken_views
from .views import SubmissionViewSet,FormSubmissionListView, FormSubmissionDetailView,RelatedFormUpdateView,RelatedFormDetailByOriginalForm, \
	CreateUserView, ListUsersView, LoginView, \
    CreateTaskView,\
    ListSubTasksByTaskIDView,\
    ListResponsibleSubTasksView,\
    CreateSubTaskView,\
    CreateAttachedTaskView,\
    ListAttachedTasksByResponsibleUserView,\
	MessageViewSet,MessageViewShowSet
  
router = DefaultRouter()
router.register(r'messages', MessageViewSet, basename='message')
router.register(r'messagesList', MessageViewShowSet, basename='messageShow')
  
urlpatterns = [  
    path('upload/', views.upload_image, name='upload_image'),
	#客户创建任务
	path('submit/', SubmissionViewSet.as_view(), name='form-submit'),
	path('list/', FormSubmissionListView.as_view(), name='form-list'),  
    path('detail/<int:id>/', FormSubmissionDetailView.as_view(), name='form-detail'), 
	path('update/<int:original_form_id>/', RelatedFormUpdateView.as_view(), name='related-form-update'),	
	path('related-forms/by-original-form/<int:original_form_id>/', RelatedFormDetailByOriginalForm.as_view(), name='related-form-by-original-form'),
	path('api/login/', LoginView.as_view(), name='login'),
	# 创建用户
    path('create_user/', CreateUserView.as_view(), name='create_user'),
    
    # 查询所有用户
    path('list_users/', ListUsersView.as_view(), name='list_users'),
	
    # 创建任务（包含无限子任务）
    path('create_task/', CreateTaskView.as_view(), name='create_task'),
    
    # 创建子任务（包含无限子任务）
    path('create_subtask/<int:task_id>/<int:user_id>', CreateSubTaskView.as_view(), name='create_subtask'),
    
    # 查询任务ID下的所有子任务信息
    path('list_subtasks/<int:task_id>/', ListSubTasksByTaskIDView.as_view(), name='list_subtasks'),
    
    # 责任人用户查看自己的子任务
    path('list_user_subtasks/<int:user_id>/', ListResponsibleSubTasksView.as_view(), name='list_user_subtasks'),
    
    # 为子任务创建附属任务
    path('create_responsible_subtask/<int:subtask_id>/', CreateAttachedTaskView.as_view(), name='create_responsible_subtask'),
    
    # 根据责任人ID查看所创建的附属任务
    path('list_responsible_subtasks/<int:responsible_id>/', ListAttachedTasksByResponsibleUserView.as_view(), name='list_responsible_subtasks'),
	
	path('list_messages/<int:receiver_id>/', include(router.urls)),

	
    path('', views.image_list, name='image_list'),
	
]

